package cn.cboard.gateway;

import java.util.List;


/**
 * @author
 * 
 * 
 * DAO able to service an SQLDescriptor
 */
public class SQLDAO  extends DAO{

	/**
	 * Constructor for SQLDao.
	 */
	protected SQLDAO() {
		super();
	}

	/**
	 * Static accessor
	 */
	public static SQLDAO get() {
		return new SQLDAO();
	}

	/**
	  * Issue a query to the database usng the supplied descriptor
	  */
	public List executeQuery(SQLDefn descriptor) throws DAOException {
		try {
			if (descriptor == null) {
				throw new DAOException("No SQL defn provided");
			}
            
			return super.executeQuery(
				descriptor.getSQL(),
				descriptor.getMaxRows(),
				descriptor.getFetchSize(),
				descriptor.getConverter(),
				descriptor.getParams());

        } catch (DAOException de) {
			throw de;
		}
		catch (Exception e) {
			throw new DAOException(e);
		}
	}
	
	


}
